public class AssignStmt {
	String id ;
	String ao;
	Expression exp;
	String sm;
	
	public AssignStmt ( String id, String ao, Expression exp, String sm){
		this.id = id;
		this.ao = ao;
		this.exp = exp;
		this.sm = sm;
	}
	public String toString(){
		String ret = "AssignStmt "+ id +"\n";

		String s = "";

		if (exp != null) {
			s +=  exp.toString();
		}
		
		return ret+s;
	}
	public void check() throws SemanticException {
		SymbolTable table = SymbolTable.getInstance();
		if (!table.contains(id) ) {
			throw new SemanticException("This identifier " + id + " hasn't been declared before");
		}
		if (exp != null) {
			if (exp.cae.ee.ae.me.pe.nm != null && table.get(id).type.type != "int"
				&& exp.cae.ee.ae.me.pe.nm != null && table.get(id).type.type != "float") {
				throw new SemanticException("Variable " + id + " can't hold a value of this type" + " " + id);	
			} else if (exp.cae.ee.ae.me.pe.st != null && table.get(id).type.type != "String") {
				throw new SemanticException("Variable " + id + " can't hold a value of this type" + " " + id);
			} else if (exp.cae.ee.ae.me.pe.bl != null && table.get(id).type.type != "boolean") {
				throw new SemanticException("Variable " + id + " can't hold a value of this type" + " " + id);
			}
		}
	}
}
